<template>
  <main>
    <div class="container">
      <h1>欢迎使用小罗VUE3待办事项！</h1>
      <todo-add :tid="todos.length" @add-todo="addTodo"></todo-add>
      <todo-filter
        :selected="selected"
        @change-filter="(e) => (selected = e.value)"
      ></todo-filter>
      <todo-list :todos="filterTodos"></todo-list>
    </div>
  </main>
</template>

<script>
import TodoAdd from "./components/TodoAdd.vue";
import TodoFilter from "./components/TodoFilter.vue";
import TodoList from "./components/TodoList.vue";
import useTodos from "./hooks/useTodos";
import useFilteredTodo from "./hooks/useFilteredTodo.js";
export default {
  name: "App",

  components: {
    TodoAdd,
    TodoFilter,
    TodoList,
  },

  setup() {
    const { todos, addTodo } = useTodos();
    const { selected, filterTodos } = useFilteredTodo(todos);

    return {
      todos,
      addTodo,
      selected,
      filterTodos,
    };
  },
};
</script>

<style>
*{
  box-sizing: border-box;
  margin: 0;
  padding: 0;

}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

main {

  width: 100vw;
  min-height: 100vh;
  display: grid;
  align-items: center;
  justify-items: center;
  background-color: rgb(203, 210, 240);
}

.container {
  width: 60%;
  max-width: 400px;
  box-shadow: 0px 0px 24px, rgba(0, 0, 0, 0.15);
  border-radius: 24px;
  padding: 48px 28px;
  background-color: rgb(245, 246, 252);
}

h1 {
  margin: 24px 0;
  font-size: 24px;
  color: #414873;
}
</style>
